package com.dayaokeji.rhythmschoolstudent.client.mine.statistics.adapter;

import android.text.TextUtils;
import android.widget.ProgressBar;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import com.dayaokeji.rhythmschoolstudent.R;
import com.dayaokeji.rhythmschoolstudent.view.StatisticsProgressView;
import com.dayaokeji.server_api.domain.StatisticsBean;


/**
 * Created by Gorden on 2018/1/30.
 */

public class AttendanceStatisticsAdapter extends BaseQuickAdapter<StatisticsBean,BaseViewHolder> {

    public AttendanceStatisticsAdapter() {
        super(R.layout.item_attendance_statistics,null);
    }

    @Override
    protected void convert(BaseViewHolder helper, StatisticsBean item) {
        helper.setText(R.id.tv_name, TextUtils.isEmpty(item.getCourseName())?item.getUserName():item.getCourseName());
        final ProgressBar progressView = helper.getView(R.id.pb_vote_count);
        helper.setText(R.id.tv_total_num,mContext.getString(R.string.ci_str,item.getTotalNum()));
        helper.setText(R.id.tv_act_num,mContext.getString(R.string.ci_str,item.getActNum()));
        helper.setText(R.id.tv_late_num,mContext.getString(R.string.ci_str,item.getLateNum()));
        helper.setText(R.id.tv_leave_early_num,mContext.getString(R.string.ci_str,item.getLeaveEarlyNum()) );
        helper.setText(R.id.tv_leave_num,mContext.getString(R.string.ci_str,item.getLeaveNum()));
        helper.setText(R.id.tv_current_rate,((int)item.getAttendanceRate())+"%");
        progressView.setProgress((int) item.getAttendanceRate());
    }
}
